package com.evon.yardmanagement.ui.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.shiro.SecurityUtils;

import com.evon.yardmanagement.model.User;
import com.evon.yardmanagement.service.RoleManagementService;
import com.evon.yardmanagement.ui.dto.RoleDTO;
import com.opensymphony.xwork2.ActionSupport;
/**
 * Action class for managing roles with the yard.
 * @author vgaurav
 *
 */
public class YardRoleAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	private List<RoleDTO> listRole = new ArrayList<RoleDTO>();
	public int selectedRoleId;
	
	
	public String execute(){
		//fetch all roles available for this vendor
		
		User loggedInUser = (User)SecurityUtils.getSubject().getSession().getAttribute("CURRENT_USER");
		listRole = RoleManagementService.getAllRoles(loggedInUser.getVendor().getId());
		return SUCCESS;
	}


	public List<RoleDTO> getListRole() {
		return listRole;
	}

	public void setListRole(List<RoleDTO> listRole) {
		this.listRole = listRole;
	}
	

}
